package com.yutian.selfservice.support;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import com.yutian.selfservice.support.utils.PageSupport;
import com.yutian.selfservice.support.utils.Result;
import com.yutian.selfservice.support.utils.ServiceType;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.sql.Date;
import java.util.List;

@Data
@JsonTypeInfo(
        use = JsonTypeInfo.Id.NAME,
        include = JsonTypeInfo.As.EXISTING_PROPERTY,
        property = "type",
        visible = true)
@JsonSubTypes({
        @JsonSubTypes.Type(value = ServiceGuide.class, name = ServiceType.PERSONAL_SERVICE),
        @JsonSubTypes.Type(value = ServiceGuide.class, name = ServiceType.LEGAL_PERSON_SERVICE),
        @JsonSubTypes.Type(value = ServiceGuide.class, name = ServiceType.PUBLIC_SERVICE),
        @JsonSubTypes.Type(value = QuestionService.class, name = ServiceType.COMMON_QUESTION),
        @JsonSubTypes.Type(value = UrlService.class, name = ServiceType.SERVICE_MAIN_NEWS),
        @JsonSubTypes.Type(value = UrlService.class, name = ServiceType.POLICY_PAPER),
        @JsonSubTypes.Type(value = UrlService.class, name = ServiceType.POLICY_UNSCRAMBLE),
        @JsonSubTypes.Type(value = UrlService.class, name = ServiceType.NOTICE),
        @JsonSubTypes.Type(value = AllService.class, name = ServiceType.ALL_SERVICE),

})
public abstract class ListService extends PageSupport {
    @Id
    private Long id;

    protected String area = "510682000000000";
    /**
     * 类型查询条件
     */
    protected Long type =0l;
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Transient
    protected String key;
    protected Date createTime;
    protected Date updateTime;
//    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
//    @Transient
//    protected String name;
//
//
//    public abstract String getName();

    /**
     * 没有分类条件  进行分页搜素
     *
     * @return
     */
    public abstract Result query();

    public abstract List<? extends ListService> selectByIds(List<Long> ids);

    /**
     * 根据id明细信息
     *
     * @return
     */
    public abstract Result details();

}
